#include <iostream>
#include <string>
#include <cstdlib>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>

using namespace std;

void myhandler(int signo)
{
    cout<<"process get a signal: "<<signo<<endl;
    exit(0);
}
int main(int argc, char *argv[])
{
    signal(2,myhandler);
    int cnt =0;
    while(true)
    {
        cout<<"process get a pid:"<<getpid()<<endl;
        sleep(1);
        if(cnt==10)
        {
            kill(getpid(),2);
            // raise(2);
            // abort();
            // kill(getpid(),6);
        }
        cnt++;
    }
    return 0;
}